<?php

namespace app\api\controller;

use app\common\controller\Api;
use think\Db;

/**
 * 首页接口
 */
class Index extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    /**
     * 首页
     *
     */
    public function index()
    {
        $this->success('请求成功');
    }

    /**
     * @return void
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     * 活动专区
     */
    public function huodonglist(){
        $huodonglist = Db::name('clinc_activity')
            ->field("doctor_ids,clinc_theme,inquiry_time,inquiry_address,id,price,clinc_score_id")
            ->order("id desc")->limit(3)
            ->select();
        if(\config('site.check_status') == 1){
            $huodonglist = [];
        }
        foreach ($huodonglist as $k=>$v){
            $huodonglist[$k]['inquiry_time'] = date('Y-m-d',$v['inquiry_time']);
            $arr = explode(',',$v['doctor_ids']);
            $d_data = Db::name('doctor')->alias('d')
                ->field('doctor_name,doctor_position,goodat,doctor_tags,image,id')->where(['id'=>$arr[0]])->find();
            $huodonglist[$k]['doctor'] = $d_data;
        }
        $this->success('请求成功',$huodonglist);
    }
    /**
     * 推荐商品
     */
    public function recgoods(){
        $gosdslist = Db::name('shopro_goods')->field("id,image,price,title")->where(['is_rec'=>1])->order("id desc")->limit(3)->select();
        $this->success('请求成功',$gosdslist);
    }
}
